import time
from appium import webdriver
from uitls.write_user_command import WriteUserCommand

class BaseDriver():
    def android_driver(self,i):
        #devicename
        #port
        write_file=WriteUserCommand()
        devices = write_file.get_value('user_info_' + str(i), 'deviceName')
        port = write_file.get_value('user_info_' + str(i), 'port')
        print('this is basedriver的',i,'port: '+port,'devices:'+devices)

        capabilities = {
            'platformName': 'Android',
            'deviceName': devices,
            'app': '/Users/chengyanan/PycharmProjects/kuai8_appium/apk/kuai8.apk',
            'appActivity': 'com.yixia.videoeditor.home.ui.SplashActivity',
            # "automationName": "uiautomator2",  # 抓取tost必须加
            # 切换activity  appwaitActivity
            "noReset": "true",
        }
        driver = webdriver.Remote("http://127.0.0.1:" + port + "/wd/hub", capabilities)
        print('http://127.0.0.1:'+port+'/wd/hub',devices)
        time.sleep(10)
        return driver

    def ios_driver(self):
        pass

    def get_driver(self):
        pass
